﻿
namespace ServerConnection
{   
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Service
    {
        private static string m_selectedLanguage = "eng";
        
        private static int m_placeId = 0;

        private static ShopServiceReference.AppServiceClient service;

        public static ShopServiceReference.AppServiceClient Instance
        {
            get
            {
                if (service == null)
                {
                    service = new ShopServiceReference.AppServiceClient("WSHttpBinding_IAppService");
                }

                if (service.State == System.ServiceModel.CommunicationState.Faulted)
                {
                    service.Abort();
                    service = new ShopServiceReference.AppServiceClient("WSHttpBinding_IAppService");
                }

                return service;
            }
        }

        public static ShopServiceReference.User CurrentUser
        {
            get;
            set;
        }

        /// <summary>
        /// Selected now language
        /// </summary>
        public static string SelectedLanguage
        {
            get {
                return m_selectedLanguage;
            }
            set
            {
                m_selectedLanguage = value;
            }
        }

        /// <summary>
        /// Place id
        /// </summary>
        public static int PlaceId
        {
            get
            {
                return m_placeId;
            }
            set
            {
                m_placeId = value;
            }
        }

        /// <summary>
        /// Place id
        /// </summary>
        public static Dictionary<string, string> GetLanguages()
        {
            Dictionary<string, string> result = new Dictionary<string, string>();

            result.Add("rus", "Русский");
            result.Add("eng", "English");

            return result;
        }

    }
}
